<?php
session_start() ;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Events
 *
 * @author Loug S
 */
class Controller_Events extends Controller_Template{
    //put your code here
    //protected $categoriesModel;
    protected function __construct(){
		parent::__construct();
		$this->selfModel = new Model_Events;
               // $this->categoriesModel = NULL;
    }
    
    public function index(){
		$title = "Liste des des Events";
		$events = $this->selModel->getAll();
					
		header('Content-Type: text/html; charset=utf-8');
		require 'View/header.tpl';
		require 'View/book/index.tpl';
		require 'View/footer.tpl';
	}
    
    public function save() {
        if (isset($_POST['eventV'])) {
            $login=$_SESSION['login'] ;
            $nom=$_POST['nom'] ;
            $result=$this->selfModel->getByName($nom) ;
            
            if(count($result)==1) {
                
                echo "Changer le titre de votre evenement" ;
            } else {
            $description=$_POST['description'] ;
            $date=$_POST['jour'].'.'.$_POST['mois'].'.'.$_POST['annee']; 
            
            $this->selfModel->ajouterEvent($login, $nom, $description, $date) ;
            }
            
        }
    }
	
    
    
}

?>
